From: Brion Vibber Date: Mon, 12 May 2008 23:37:51 +0000 (+0000) Subject: Revert r34559 and fix r34542 -- include rightclickedit.js for 'edit on right click... X-Git-Tag: 1.31.0-rc.0~47688 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=610b660d8eca47379bf7c9435b6651eccc61110d;p=lhc%2Fweb%2Fwiklou.git Revert r34559 and fix r34542 -- include rightclickedit.js for 'edit on right click' pref, must have forgot to finish it up before commit :D --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index dbd275da4c..67a050dfbe 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -794,6 +794,10 @@ class OutputPage { $this->addScriptFile( 'mwsuggest.js' ); } } + + if( $wgUser->getBoolOption( 'editsectiononrightclick' ) ) { + $this->addScriptFile( 'rightclickedit.js' ); + } # Buffer output; final headers may depend on later processing diff --git a/includes/Skin.php b/includes/Skin.php index 9ee07ac55c..dbb6001162 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -544,12 +544,6 @@ END; } $a['onload'] = $wgOut->getOnloadHandler(); - if( $wgUser->getOption( 'editsectiononrightclick' ) ) { - if( $a['onload'] != '' ) { - $a['onload'] .= ';'; - } - $a['onload'] .= 'setupRightClickEdit()'; - } $a['class'] = 'mediawiki ns-'.$wgTitle->getNamespace(). ' '.($wgContLang->isRTL() ? "rtl" : "ltr"). diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 0c73d15c7f..3422ee1e1d 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -436,11 +436,7 @@ class SkinTemplate extends Skin { } else { $tpl->set('body_ondblclick', false); } - if( $this->iseditable && $wgUser->getOption( 'editsectiononrightclick' ) ) { - $tpl->set( 'body_onload', 'setupRightClickEdit()' ); - } else { - $tpl->set( 'body_onload', false ); - } + $tpl->set( 'body_onload', false ); $tpl->set( 'sidebar', $this->buildSidebar() ); $tpl->set( 'nav_urls', $this->buildNavUrls() ); diff --git a/skins/common/rightclickedit.js b/skins/common/rightclickedit.js new file mode 100644 index 0000000000..83d552a2c6 --- /dev/null +++ b/skins/common/rightclickedit.js @@ -0,0 +1,48 @@ +function setupRightClickEdit() { + if (document.getElementsByTagName) { + var spans = document.getElementsByTagName('span'); + for (var i = 0; i < spans.length; i++) { + var el = spans[i]; + if(el.className == 'editsection') { + addRightClickEditHandler(el); + } + } + } +} + +function addRightClickEditHandler(el) { + for (var i = 0; i < el.childNodes.length; i++) { + var link = el.childNodes[i]; + if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { + var editHref = link.getAttribute('href'); + // find the enclosing (parent) header + var prev = el.parentNode; + if (prev && prev.nodeType == 1 && + prev.nodeName.match(/^[Hh][1-6]$/)) { + prev.oncontextmenu = function(e) { + if (!e) { e = window.event; } + // e is now the event in all browsers + var targ; + if (e.target) { targ = e.target; } + else if (e.srcElement) { targ = e.srcElement; } + if (targ.nodeType == 3) { // defeat Safari bug + targ = targ.parentNode; + } + // targ is now the target element + + // We don't want to deprive the noble reader of a context menu + // for the section edit link, do we? (Might want to extend this + // to all 's?) + if (targ.nodeName.toLowerCase() != 'a' + || targ.parentNode.className != 'editsection') { + document.location = editHref; + return false; + } + return true; + }; + } + } + } +} + +hookEvent("load", setupRightClickEdit); diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 839e624523..812710b73d 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -461,53 +461,6 @@ function akeytt( doId ) { } } -function setupRightClickEdit() { - if (document.getElementsByTagName) { - var spans = document.getElementsByTagName('span'); - for (var i = 0; i < spans.length; i++) { - var el = spans[i]; - if(el.className == 'editsection') { - addRightClickEditHandler(el); - } - } - } -} - -function addRightClickEditHandler(el) { - for (var i = 0; i < el.childNodes.length; i++) { - var link = el.childNodes[i]; - if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { - var editHref = link.getAttribute('href'); - // find the enclosing (parent) header - var prev = el.parentNode; - if (prev && prev.nodeType == 1 && - prev.nodeName.match(/^[Hh][1-6]$/)) { - prev.oncontextmenu = function(e) { - if (!e) { e = window.event; } - // e is now the event in all browsers - var targ; - if (e.target) { targ = e.target; } - else if (e.srcElement) { targ = e.srcElement; } - if (targ.nodeType == 3) { // defeat Safari bug - targ = targ.parentNode; - } - // targ is now the target element - - // We don't want to deprive the noble reader of a context menu - // for the section edit link, do we? (Might want to extend this - // to all 's?) - if (targ.nodeName.toLowerCase() != 'a' - || targ.parentNode.className != 'editsection') { - document.location = editHref; - return false; - } - return true; - }; - } - } - } -} - var checkboxes; var lastCheckbox;